<?php

namespace App\Models;

use Dcat\Admin\Traits\HasDateTimeFormatter;

use Illuminate\Database\Eloquent\Model;

class MebConsumption extends Model
{
	use HasDateTimeFormatter;
    protected $table = 'four_consumption';



    public function es()
    {
        return $this->hasOne(FourPatient::class,'id','patient_id');
    }
    public function source()
    {
        return $this->hasOne(FourSource::class,'id','source_id');
    }
    public function type()
    {
         return $this->hasOne(Fourbusiness::class,'id','bussiness_type');
    }

    public function types()
    {
        return $this->hasOne(FourType::class,'id','drug_id');
    }

    public function pay()
    {
        return $this->hasOne(FourPay::class,'id','pay_type');
    }

      protected $fillable = ['created_at','order_id','patient_id','visit_id','source_id','bussiness_type','drug_id','pay_type','money','status'];


    /*//修改患者姓名
    public function setPatientIdAttribute($value)
    {
        $patient = FourPatient::where('patient_name', $value)->first();
        if (!$patient) {
            throw new \Exception('患者姓名填写错误,请重新填写');
        }
        $this->attributes['patient_id'] = $patient['id'];
    }

    //修改就诊号
    public function index($value)
    {
        $card = FourPatient::where('visit_card', $value)->first();
        if (!$card) {
            throw new \Exception('就诊号填写错误,请重新填写');
        }
        $this->attributes['visit_id'] = $card['id'];

    }*/




















}
